package com.example.mediator.bo;

import com.example.mediator.Mediator;

public class User {
    private final String name;
    private final Mediator mediator;

    public User(String name, Mediator mediator) {
        this.name = name;
        this.mediator = mediator;
    }

    public String getName() {
        return name;
    }

    // 私发
    public void sendPrivate(String name, String message) {
        mediator.sendPrivateMessage(this.name, name, message);
    }

    // 群发
    public void send(String message) {
        System.out.println(name + " 大声说: " + message);
        mediator.sendMessage(name, message);
    }

    public void receive(String name, String message) {
        System.out.println(this.name + " 收到消息: " + name + " 悄悄的说: " + message);
    }

    public void receive(String message) {
        System.out.println(name + " 收到消息: " + message);
    }


}
